﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyHealthOnline.Business;

namespace MyHealthOnline.Specialist.Controls
{
    public partial class Message : System.Web.UI.UserControl
    {
        public int ConsultId
        {
            get
            {
                if (ViewState["ConsultId"] == null)
                {
                    return -1;
                }
                return Convert.ToInt32(ViewState["ConsultId"].ToString());
            }
            set
            {
                ViewState["ConsultId"] = value;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnAddMessage_Click(object sender, EventArgs e)
        {
            var creationDate = DateTime.Now;
            var status = MessageStatus.GetMessageStatus(MessageStatusEnum.WaitingForPatientReaction);
            var messageText = txtMessage.Text;

            MessageBusiness.AddMessage(creationDate, status, messageText, true, ConsultId);
            txtMessage.Text = "";
        }
    }
}